//初始化
$(function () {
	// 添加页面列表信息
    gridObj = $.fn.bsgrid.init('g_tabYeh', {
        dataType: 'json',
        ajaxType: 'get',
        url: server_url+'/rest/project/list.do?token='+token+'&ran='+Math.random(),
        autoLoad: true,
        pageSizeSelect: true,
        stripeRows: true,
        pageSize: 10,
        displayBlankRows: false,
        isProcessLockScreen:true,
        rowSelectedColor:false
    });
    $('#qx').append('<span style="padding-left:5px;">全选</span>');
});

// 添加操作项信息
function operate(record, rowIndex, colIndex, options) {
	return '<a href="javascript:edit(\''
			+ gridObj.getRecordIndexValue(record, 'id')
			+ '\');">编辑</a><a href="javascript:userManage(\''
			+ gridObj.getRecordIndexValue(record, 'id')
			+ '\');">人员管理</a><a href="javascript:processManage(\''
			+ gridObj.getRecordIndexValue(record, 'id')
			+ '\');">进程管理</a>';
}
// 获取checkbox选中
function deleteByIds() {
	var ids = gridObj.getCheckedValues('id').toString();
	if (ids == "") {
		easyDialog.open({
			container:{
				header:"温馨提示",
				content:"请选择要操作的记录！"
			},
			autoClose : 1000
		});
	} else {
		easyDialog.open({
			  container : {
				  header:"温馨提示",
			    content : '您确定要删除吗？',
			    yesFn : function(){
			    	$.ajax({
						url : server_url+'/rest/project/delete.do?token='+token+'&ran='+Math.random(),
						type : 'post',
						dataType : 'json',
						data : {
							ids : ids
						},
						success : function(data) {
							if (data.retCode = "0000") {
								var url = "projectList.do?ran="+Math.random();
								tl_config.loadToWorkArea(url);
//								$(".g_rightMidden").load("projectList.do?ran="+Math.random());
							}else{
								easyDialog.open({
									container:{
										header:"温馨提示",
										content:data.retMsg
									},
									autoClose : 1000
								});
							}
						}
					});
			    },
			    noFn : true
			  }
		});
	}
}
// 查询
function search() {
	if(checkForm('myform')){
		return;
	}
	searchParames = $('#myform').serialize();
	if ($('#projectName').val() == '') {
		gridObj.search('');
	} else {
		gridObj.search(searchParames);
	}
}
// 添加
function add() {
	var url = "projectAdd.do?ran="+Math.random();
	tl_config.loadToWorkArea(url);
}
// 编辑
function edit(id) {
	var url = "projectEdit.do?id="+id+"&ran="+Math.random();
	tl_config.loadToWorkArea(url);
}
// 删除
function del() {
	deleteByIds();
}
//人员管理
function userManage(id) {
	var url = "projectStaffList.do?projectId="+id+"&ran="+Math.random();
	project_Obj.url = url;
	tl_config.loadToWorkArea(url);
}
//进程管理
function processManage(id) {
	var url = "processList.do?projectId="+id+"&ran="+Math.random();
	project_Obj.url = url;
	tl_config.loadToWorkArea(url);
}
